package org.marketlive.biz.session.context;

/*
 (C) Copyright MarketLive. 2006. All rights reserved.
 MarketLive is a trademark of MarketLive, Inc.
 Warning: This computer program is protected by copyright law and international treaties.
 Unauthorized reproduction or distribution of this program, or any portion of it, may result
 in severe civil and criminal penalties, and will be prosecuted to the maximum extent
 possible under the law.
 */

/**
 * Called when a customer logs in.
 *
 * The possible return status values for login method are defined as follows:
 *
 * LOGIN_PASS Return this value when the login was successful. All other login extensions will be ignored once the first
 * one passes.
 *
 * LOGIN_FAIL Return this value if the login fails. All other login extensions will be ignored once the first one fails.
 *
 * LOGIN_SKIP Return this value to indicate that the login neither passed or failed. The login process will then
 * evaluate the next login extension.
 */
public interface ILoginExtension {

    /**
     * This status is returned if login was successful.
     *
     */
    int LOGIN_PASS = 1;

    /**
     * This status is returned if login can be bypassed. Other login extensions will still be processed.
     *
     */
    int LOGIN_SKIP = 0;

    /**
     * This status is returned if login is invalid.
     *
     * This will cause the login session to fail.
     *
     */
    int LOGIN_FAIL = -1;

    /**
     * This method is called when a customer logs in.
     *
     * @param commerceSession the currently used commerce session.
     * @param userId the customer's primary key as a string.
     * @param password the customer's password as a string.
     * @return returns a login status result (LOGIN_PASS, LOGIN_FAIL, or LOGIN_SKIP).
     */
    int login(ICommerceSession commerceSession, String userId, String password);
}
